﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FarmPropertiesEditor.aspx.cs" MasterPageFile="~/_admin/admin.master"
    Inherits="Trentacular.SharePoint.Features.Web.UI.FarmPropertiesEditor, Trentacular.SharePoint.Features.Web.UI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=544f3330e04bd2bc" %>

<%@ Register TagPrefix="sp" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="t" Namespace="Trentacular.SharePoint.Features.Web.UI.WebControls" Assembly="Trentacular.SharePoint.Features, Version=1.0.0.0, Culture=neutral, PublicKeyToken=544f3330e04bd2bc" %>

<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>

<asp:Content contentplaceholderid="PlaceHolderPageTitle" runat="server">
	Manage Farm Properties
</asp:content>
<asp:Content contentplaceholderid="PlaceHolderPageTitleInTitleArea" runat="server">
	Manage Farm Properties
</asp:Content>
<asp:content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
</asp:content>
<asp:content contentplaceholderid="PlaceHolderPageDescription" runat="server">
    Use this page to manage properties stored in the Farm's property bag
</asp:content>
<asp:content contentplaceholderid="PlaceHolderMain" runat="server">

    <table border="0" cellspacing="0" cellpadding="0" width="100%">
	    <wssuc:InputFormSection
		     Title="Add New Property"
		     runat="server">
		     <Template_Description>
    			 
		     </Template_Description>
		     <Template_InputFormControls>
		        <wssuc:InputFormControl runat="server" LabelText="Key">
				    <Template_Control>
					    <sp:InputFormTextBox ID="txtKey" runat="server" Title="Key"
					        class="ms-long" /><sp:InputFormRequiredFieldValidator runat="server"
					        ControlToValidate="txtKey"
					        ValidationGroup="AddProperty"
						    ErrorMessage="Key is required" />
				    </Template_Control>
			    </wssuc:InputFormControl>
		        <wssuc:InputFormControl runat="server" LabelText="Value">
				    <Template_Control>
					    <sp:InputFormTextBox ID="txtValue" runat="server" Title="Value"
					        class="ms-long" /><sp:InputFormRequiredFieldValidator runat="server"
					        ControlToValidate="txtValue"
						    ValidationGroup="AddProperty"
						    ErrorMessage="Value is required" />
				    </Template_Control>
			    </wssuc:InputFormControl>
		     </Template_InputFormControls>
	     </wssuc:InputFormSection>
	     <wssuc:ButtonSection runat="server" ShowStandardCancelButton="false">
		    <Template_Buttons>
			    <asp:Button runat="server" class="ms-ButtonHeightWidth"
			        OnClick="btnAdd_Click" Text="Add" ValidationGroup="AddProperty" />
		    </Template_Buttons>
	    </wssuc:ButtonSection>
    </table>

    <t:DelegateDataSource ID="dsProperties" runat="server"
        AutoSort="true"
        OnSelect="GetProperties"
        OnUpdate="UpdateProperty"
        OnDelete="DeleteProperty" />

    <h3 class="ms-standardheader">Farm Properties</h3>
	<sp:SPGridView ID="gvProperties" runat="server" width="100%" DataSourceId="dsProperties" AutoGenerateColumns="false" DataKeyNames="Key" AllowSorting="true">
		<AlternatingRowStyle CssClass="ms-alternating" />
		<Columns>
			<asp:BoundField HeaderText="Key" DataField="Key" SortExpression="Key" ReadOnly="true" />
			<asp:TemplateField HeaderText="Value">
			    <ItemTemplate><%# Server.HtmlEncode(Eval("Value").ToString()) %></ItemTemplate>
			    <EditItemTemplate>
			        <asp:TextBox ID="txtUpdateValue" runat="server" CssClass="ms-long"
			            Text='<%# Bind("Value") %>' />
			        <asp:LinkButton runat="server" CommandName="Update" Text="Update" />
			        <asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
			        <sp:InputFormRequiredFieldValidator runat="server"
				        ControlToValidate="txtUpdateValue"
					    ErrorMessage="Value is required" />
			    </EditItemTemplate>
			</asp:TemplateField>
			<asp:ButtonField HeaderText="Edit" CommandName="Edit"
			    ButtonType="Image" ImageUrl="/_layouts/images/edit.gif" Text="Edit" />
			<asp:ButtonField HeaderText="Delete" CommandName="Delete"
			    ButtonType="Image" ImageUrl="/_layouts/images/delete.gif" Text="Delete" />
		</Columns>
	</sp:SPGridView>
	
</asp:content>
